﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FM_BarNote : FM_BaseNote
{
    public bool lineEnd = false; // set it to true if it is a line-end bar

    public FM_BarNote(FM_ScoreBase score) : base(FM_NoteType.BAR, score)
    {
    }

    public FM_BarNote(FM_ScoreBase score, Color Color) : base(FM_NoteType.BAR, score)
    {
        this.color = Color;
    }

    public override float GetDisplacement()
    {
        return 0.0f;
    }

    public override string AsString()
    {
        return "";
    }

    public override float WidthAccidental()
    {
        return 0;
    }

    public override float WidthNoteNoStem()
    {
        if (score != null)
            return FM_Const.dpTOpx(1);
        else
            return 0;
    }

    public override float WidthNote()
    {
        return WidthNoteNoStem();
    }

    public override float WidthDot()
    {
        return 0;
    }

    public override void DrawNote(ScoreCanvas canvas)
    {
        if (!IsBlurred() && !IsVisible()) return;
        base.DrawNote(canvas);
        if (score == null) return;

        //if (IsBlurred())
        //    score.score.Font.SetMaskFilter(new BlurMaskFilter(15, Blur.Normal));
        //else
        //    score.score.Font.SetMaskFilter(null);

        float BarYs = StartY1;
        float BarYe;

        if (StartY2 == 0)
            BarYe = StartY1 + 4 * score.score.GetDistanceBetweenStaveLines();
        else
            BarYe = StartY2 + 4 * score.score.GetDistanceBetweenStaveLines();

        canvas.DrawRect(GetStartX() + GetPaddingLeft(), BarYs, GetStartX() + GetPaddingLeft() + FM_Const.dpTOpx(1), BarYe, score.score.Font);

        score.score.Font.Color = score.score.GetColor();
        //score.score.Font.SetMaskFilter(null);
    }

    public override float Left()
    {
        return GetStartX();
    }

    public override float Bottom()
    {
        return StartY1;
    }

    public override float Right()
    {
        return GetStartX() + GetPaddingLeft() + WidthNote();
    }

    public override float Top()
    {
        if (score == null) return 0;

        if (StartY2 == 0)
            return StartY1 + 4 * score.score.GetDistanceBetweenStaveLines();

        return StartY2 + 4 * score.score.GetDistanceBetweenStaveLines();
    }
}
